#include<bits/stdc++.h>
using namespace std;

const int N = 1e7 + 10, INF = 0x3f3f3f3f;

int n, m, root, idx;
struct node
{
    int key, pri, siz;
    int ls, rs;
}tr[N];

void pushup(int x) { tr[x].siz = tr[tr[x].ls].siz + tr[tr[x].rs].siz + 1; }

int newnode(int x)
{
    int p = ++idx;
    tr[p].ls = tr[p].rs = 0;
    tr[p].siz = 1;
    tr[p].key = x, tr[p].pri = rand();
    return p;
}

void split(int x, int k, int& l, int& r)
{
    if (x == 0) { l = r = 0; return; }
    if (tr[x].key <= k) {
        l = x;
        split(tr[x].rs, k, tr[x].rs, r);
    } else {
        r = x;
        split(tr[x].ls, k, l, tr[x].ls);
    }
    pushup(x);
}

int merge(int l, int r)
{
    if (l == 0 || r == 0) return l + r;
    if (tr[l].pri > tr[r].pri) {
        tr[l].rs = merge(tr[l].rs, r);
        pushup(l);
        return l;
    } else {
        tr[r].ls = merge(l, tr[r].ls);
        pushup(r);
        return r;
    }
}

void insert(int x)
{
    int l, r, p = newnode(x);
    split(root, x, l, r);
    root = merge(merge(l, p), r);
}

void del(int x)
{
    int l, r, p;
    split(root, x, l, r);split(l, x - 1, l, p);
    p = merge(tr[p].ls, tr[p].rs);
    root = merge(merge(l, p), r);
}

int Rank(int x)
{
    int l, r;
    split(root, x - 1, l, r);
    int res = tr[l].siz;
    root = merge(l, r);
    return res + 1;
}

int kth(int x, int k)
{
    if (tr[tr[x].ls].siz + 1 == k) return tr[x].key;
    if (tr[tr[x].ls].siz >= k) return kth(tr[x].ls, k);
    return kth(tr[x].rs, k - tr[tr[x].ls].siz - 1);
}

int Precursor(int x)
{
    int l, r;
    split(root, x - 1, l, r);
    int res = kth(l, tr[l].siz);
    root = merge(l, r);
    return res;
}

int Successor(int x)
{
    int l, r;
    split(root, x, l, r);
    int res = kth(r, 1);
    root = merge(l, r);
    return res;
}

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

void solve()
{
    n = read();m = read();
    for (int i = 1;i <= n;i++) insert(read());

    int op, x, last = 0, ans = 0;
    while (m--) {
        op = read();x = read(); x ^= last;
        if (op == 1) { insert(x); }
        if (op == 2) { del(x); }
        if (op == 3) { ans ^= (last = Rank(x)); }
        if (op == 4) { ans ^= (last = kth(root, x)); }
        if (op == 5) { ans ^= (last = Precursor(x)); }
        if (op == 6) { ans ^= (last = Successor(x)); }
    }
    cout << ans;
}

signed main()
{
    //ios::sync_with_stdio(0);
    //cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    srand(time(NULL));
    int T = 1;
    //cin>>T;
    for (int i = 1;i <= T;i++) {
        solve();
    }
}